package org.mil.bean.bo;

import org.mil.bean.dom.H264ConfigInfoDO;

/**
 * h264编码参数信息类
 * @author HZK
 *
 */
public class H264ConfigInfo {
	public byte cabac;
	public byte ref;
	public byte subme;
	public byte bframes;
	public char me;	//[u]umh,[h]hex
	public char rc;	//[c]crf,[2]2pass
	public int crf_x100;
	public int keyint;
	public byte keyint_min; 
	public int bitrate;
	
	public static H264ConfigInfo newInstance(String source) {
		if (source==null) return null;
		H264ConfigInfo ci = new H264ConfigInfo();
		ci.read(source);
		return ci;
	}

	public void read(String source){
		H264ConfigInfoDO s=H264ConfigInfoDO.newInstance(source);
		try {
			cabac=Byte.valueOf(s.getCabac());
			ref=Byte.valueOf(s.getRef());
			subme=Byte.valueOf(s.getSubme());
			bframes=Byte.valueOf(s.getBframes());
			//tentative ways:
			me=s.getMe().charAt(0);
			rc=s.getRc().charAt(0);
			
			if (rc=='c') crf_x100=(int) (Double.valueOf(s.getCrf())*100);
			else bitrate=Integer.valueOf(s.getBitrate());
			keyint=Integer.valueOf(s.getKeyint());
			keyint_min=Byte.valueOf(s.getKeyint_min());
			
			
		} catch (NumberFormatException e) {
			//e.printStackTrace();
		}
	}
}
